﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SMA.GENTEv1.Dados;

namespace SMA.GENTEv1
{
    public class StatusFormacao
    {
        #region Variaveis Membro
        private int _idStatusFormacao;
        private string _descricao;
        private GENTEEntities _context;
        #endregion

        #region Parametros
        public int IdStatusFormacao
        {
            get { return _idStatusFormacao; }
            set { _idStatusFormacao = value; }
        }
        public string Descricao
        {
            get { return _descricao; }
            set { _descricao = value; }
        }
        #endregion

        #region Construtores
        public StatusFormacao()
        {
            try
            {
                _context = new GENTEEntities();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public StatusFormacao(int idStatusFormacao)
        {
            try
            {
                _context = new GENTEEntities();
                Carregar(idStatusFormacao);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion

        #region Metodos Privados
        private void Carregar(int idStatusFormacao)
        {
            try
            {
                var consulta = from sf in _context.tab_status_formacao
                               where sf.id_status_fomarcao == idStatusFormacao
                               select sf;

                var listConsulta = consulta.ToList();

                foreach (var list in listConsulta)
                {
                    this.IdStatusFormacao = list.id_status_fomarcao;
                    this.Descricao = list.descricao;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion

        #region Metodos Publicos

        #region Metodos de Selecao
        public List<StatusFormacao> SelectAll()
        {
            try
            {
                List<StatusFormacao> listStatusFormacao = new List<StatusFormacao>();

                var consulta = from sf in _context.tab_status_formacao
                               select sf;

                var listConsulta = consulta.ToList();

                foreach (var list in listConsulta)
                {
                    StatusFormacao statusFormacao = new StatusFormacao();
                    statusFormacao.IdStatusFormacao = list.id_status_fomarcao;
                    statusFormacao.Descricao = list.descricao;

                    listStatusFormacao.Add(statusFormacao);
                }

                return listStatusFormacao;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion

        #region Metodos de Persistencia
        #endregion

        #endregion
    }
}
